Add is_word fast path for Codepoint{-1}#5444
Open
bscuron wants to merge 1 commit intomawww:masterfrom
Open
Conversation
Owner
|
Can you expand on when this makes a difference ? -1 codepoints should be rare, as they are what we use whenever we fail to decode utf8. |
Contributor
Author
I believe it only matters in src/ranked_match when reading the previous utf codepoint for completion ordering. RankedMatch::operator< // compare codepoints
it1 = utf8::character_start(it1, last1);
it2 = utf8::character_start(it2, last2);
const auto itsave1 = it1, itsave2 = it2;
const auto cp1 = utf8::read_codepoint(it1, end1);
const auto cp2 = utf8::read_codepoint(it2, end2);
if (cp1 != cp2)
{
const auto cplast1 = utf8::prev_codepoint(itsave1, begin1);
const auto cplast2 = utf8::prev_codepoint(itsave2, begin2);
const bool is_wb1 = is_word_boundary(cplast1, cp1);
const bool is_wb2 = is_word_boundary(cplast2, cp2);
if (is_wb1 != is_wb2)
return is_wb1;
const bool low1 = is_lower(cp1);
const bool low2 = is_lower(cp2);
if (low1 != low2)
return low1;
return order(cp1) < order(cp2);
}Maybe it makes more sense to add the check for invalid policy here if you think it is worth adding at all. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.